// pages/component/iaudio.js
Component({
   /**
    * 组件的属性列表
    */
   properties: {
      name: String,
      singer: String,
      duration: String,
      src: String,
      isPlay:Boolean
   },

   /**
    * 组件的初始数据
    */
   data: {
      myAudio: {},
      icon: "play",
      isPlaying: false
   },
   ready() {
      var myAudio1 = wx.createInnerAudioContext();
      myAudio1.src = this.data.src;
      console.log("获取的数据:"+this.data.isPlay)
      var isPlaying = this.data.isPlay
      
      this.setData({
         myAudio: myAudio1,
         isPlaying:isPlaying
      })

     


     
     if (isPlaying) {
      this.setData({
         icon: "pause",
      })
   } else {
      this.setData({
         icon: "play",
      })
   }

   },

   /**
    * 组件的方法列表
    */
   methods: {
      disPlay: function () {
         var isPlaying = this.data.isPlaying

         if (!isPlaying) {
            this.data.myAudio.play()
            this.setData({
               icon: "pause",
               isPlaying: true
            })
         } else {
            this.data.myAudio.pause()
            this.setData({
               icon: "play",
               isPlaying: false
            })
         }


      }
   }
})
